package com.example.administrator.myapplication;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.administrator.myapplication.util.DB;

/**
 * Created by Administrator on 2020/12/10.
 */

public class SignInActivity extends AppCompatActivity {

    private EditText sidnInUsernameEt;
    private EditText sidnInStudentIdEt;
    private Button signInBtn;
    private String usernameStr;
    private String studentidStr;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_signin);
        initView();

        initEvent();
    }
    private void initView(){
        sidnInUsernameEt = findViewById(R.id.sign_in_username_et);
        sidnInStudentIdEt = findViewById(R.id.sign_in_student_id_et);
        signInBtn = findViewById(R.id.sign_in_btn);
    }
    private void initData(){
        usernameStr = sidnInUsernameEt.getText().toString()+"";
        studentidStr = sidnInStudentIdEt.getText().toString()+"";
    }
    private void initEvent(){
        signInBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                initData();
                DB db=new DB(SignInActivity.this);
                Boolean result= db.signInsert(usernameStr,studentidStr);
                if (result){
                    Toast.makeText(SignInActivity.this, "注册成功", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

}
